package com.controller;

import com.domain.Company;
import com.domain.Student;
import com.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;



@Controller
@RequestMapping("/teacher")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    @RequestMapping(value = "/tquery")
    public ModelAndView tquery(Integer sid){
        List<Student> students= teacherService.tquery(sid);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("teacher_query",students);
        modelAndView.setViewName("teacher_query");
        return modelAndView;
    }

    @RequestMapping(value = "/cquery")
    public ModelAndView cquery(Integer cid){
        List<Company> companys= teacherService.cquery(cid);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("company_rec",companys);
        modelAndView.addObject("cid",cid);
        modelAndView.setViewName("company_rec");
        return modelAndView;
    }

    @RequestMapping(value = "/squery")
    public ModelAndView squery(Integer sid){
        List<Student> students= teacherService.tquery(sid);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("teacher_find",students);
        modelAndView.setViewName("teacher_find");
        return modelAndView;
    }

    @RequestMapping(value = "/sfind")
    public ModelAndView sfind(Integer sid){
        List<Student> students= teacherService.sfind(sid);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("teacher_grade",students);
        modelAndView.setViewName("teacher_grade");
        return modelAndView;
    }

}
